use super::Input;

#[derive(Clone, Debug,Default)]
pub struct TaskInfo {
    pub name: String,
    pub help: String,
    pub flags: Vec<(String, String, String)>, //参数名称 默认 帮助
}

impl TaskInfo{
    pub fn new<S:ToString,H:ToString>(name:S,help:H)->Self{
        Self{
            name:name.to_string(),
            help:help.to_string(),
            flags:vec![],
        }
    }
    pub fn register_arg<A:ToString,D:ToString,H:ToString>(mut self,arg:A,default:D,help:H)->Self{
        self.flags.push((arg.to_string(),default.to_string(),help.to_string()));self
    }
}

#[async_trait::async_trait]
pub trait Task : Send + Sync {
    fn info(&self)->TaskInfo;
    async fn run(&self,input:Input)->anyhow::Result<()>;
    async fn exit(&self,_input:Input)->anyhow::Result<()>{
        Ok(())
    }
}